
// const uniID = require('uni-id-common')
// const getUserInfo = async function(that){
// 	const token =that.getUniIdToken()
// 	const clientInfo = that.getClientInfo()
// 	const uniIDIns = uniID.createInstance({ // 创建uni-id实例，其上方法同uniID
// 				clientInfo
// 			})			
// 	const userInfo = await uniIDIns.checkToken(token)
	
// }

// module.exports =  {
// 	getUserInfo
// }

const uniID = require('uni-id-common');

module.exports = {
  async getUserInfo(that) {
    try {
      const token = that.getUniIdToken();
      const clientInfo = that.getClientInfo();
      
      const uniIDIns = uniID.createInstance({
        clientInfo
      });
      
      const userInfo = await uniIDIns.checkToken(token);
      
      if (!userInfo) {
        throw new Error('用户信息无效');
      }
      
      return userInfo;
    } catch (error) {
      console.error('获取用户信息失败:', error);
      throw new Error('获取用户信息失败');
    }
  }
};